import 'package:flutter/material.dart';

import '../../../config.dart';
import '../../resources/resources.dart';
import '../widget.dart';


class MyMenuItem extends StatefulWidget {
  final String title;
  final VoidCallback? onTap;
  const MyMenuItem({Key? key, required this.title, this.onTap}) : super(key: key);



  @override
  State<MyMenuItem> createState() => _MyMenuItemState();
}

class _MyMenuItemState extends State<MyMenuItem> {

  bool hover = false;

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: widget.onTap,
      hoverColor: Colors.transparent,
      onHover: (hover){
        setState(() {
          this.hover = hover;
        });
      },
      child: Container(
        //圆角
        decoration: BoxDecoration(
          color: hover?const Color(0xff6a9bfb):Colors.transparent,
          borderRadius: BorderRadius.circular(4),
        ),
        padding: const EdgeInsets.only(left: 8,right: 8,top: 2,bottom: 2),
        margin: const EdgeInsets.only(left: 0,right: 0,top: 1,bottom: 1),
        child: Row(
          children: [
            Expanded(child: MyText(widget.title,size: 14,textAlign: TextAlign.start,color: hover ? Colors.white:JmConfig.defTextStyle.color,)),
            gaph8,
          ],
        ),
      ),
    );
  }
}

class MyMenuDivider extends StatelessWidget {
  const MyMenuDivider({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      color: JmColors.div,
      height: 1,
      margin: const EdgeInsets.only(left: 8,right: 8,top: 4,bottom: 4),
    );
  }
}